getExtra()在onClickListener中引用时给出一个空值 您所在的位置:网站首页 python 给空值赋值 getExtra()在onClickListener中引用时给出一个空值

getExtra()在onClickListener中引用时给出一个空值

2023-03-22 05:44| 来源: 网络整理| 查看: 265

我不确定为什么我在下面获取激活码的空值。任何关于它如何工作的指针/解释都会非常有用。由于getExtra()在onClickListener中引用时给出一个空值

protected void onCreate(Bundle savedInstanceState) { . . . Bundle bundle = getIntent().getExtras(); final String activationcode = bundle.getString("activationcode"); etActivationCode = (EditText)findViewById(R.id.et_LoginForgotPasswordOk_Code); btnForgotPasswordOk = (Button)findViewById(R.id.btn_LoginForgotPasswordOk_OK); btnForgotPasswordOk.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub String inputActivationCode = etActivationCode.getText().toString(); if(inputActivationCode == activationcode){ //the value of activationcode above is null. Hence doesn't match ever } } });

但是,如果我这样做下面的激活码值可以理论上,应该使用equalsIgnoreCase()比较两个字符串引用

@Override public void onClick(View arg0) { new CheckMatch().execute(activationcode); //the value of activationcode can now be accessed in the AsyncTask class CheckMatch }

来源

2015-02-10 Jagatjeet

+0

你确定为空?或者它不匹配,因为你使用'=='来比较字符串? – Blackbelt 2015-02-10 20:36:43

+0

使用等于比较字符串 – vinitius 2015-02-10 20:37:05

+0

它应该以相同的方式工作两次 – Leonidos 2015-02-10 20:43:50



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有